<!DOCTYPE html>
<!--suppress ThymeleafVariablesResolveInspection-->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Responsive Admin Dashboard Template">
    <meta name="keywords" content="admin,dashboard">
    <meta name="author" content="skcats">
    <title></title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all" />
    <link th:href="@{/assets/plugins/bootstrap/css/bootstrap.min.css}" rel="stylesheet">
    <link th:href="@{/assets/plugins/font-awesome/css/font-awesome.min.css}" rel="stylesheet">
    <link th:href="@{/assets/css/custom.css}" rel="stylesheet">
</head>
<style>
    .layui-table-page {
        text-align: center;
    }

    .utable .layui-laypage .layui-laypage-curr .layui-laypage-em {
        background-color: #1E9FFF;
    }
    .layui-input-inline{margin-left: 50px;}
    .layui-form-item{margin-top: 20px;}
    .layui-form-label{width: 80px;}
    .layui-table-view thead th {
        text-align: center;
        font-weight: bold;
    }
    .layui-table-view tbody td {
        text-align: center;
    }
    .layui-form-label{

    }
</style>
<body>
<!--表格功能-->
<script type="text/html" id="bar">
    <a class="layui-btn layui-btn-green layui-btn-xs" lay-event="edit">
        <i class="layui-icon">&#xe642;</i>编辑
    </a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">
        <i class="layui-icon">&#xe640;</i>丢弃
    </a>
</script>

<!--头工具栏-->
<script id="toolbarDemo" type="text/html">
    <div class="layui-btn-container">
        <button id="add" class="layui-btn layui-btn-sm">新增</button>
    </div>
</script>

<!--数据表格  数据表格使用的是方法渲染-->
<div class="utable">
    <table class="layui-table"
           lay-data="{width:1270,height:500, url:'/chatrecord/chatrecorddata', page:true, id:'tab',toolbar: '#toolbarDemo'}"
           lay-filter="tab">
        <thead>
        <tr>
            <th lay-data="{field:'Chatid', width:80}">编号</th>
            <th lay-data="{field:'stuname', width:100, edit: 'false'}">学生名称</th>
            <th lay-data="{field:'emp_Name',width:100}">员工名称</th>
            <th lay-data="{field:'addr', width:100}">地址</th>
            <th lay-data="{field:'sayscon',edit: 'false'}">谈心内容</th>
            <th lay-data="{field:'chatDate', width:115}">时间</th>
            <th lay-data="{fixed: 'right', title:'操作', toolbar: '#bar',width:180}"></th>
        </tr>
        </thead>
    </table>
</div>
</body>
<script th:src="@{/assets/plugins/jquery/jquery-3.1.0.min.js}"></script>
<script th:src="@{/layui/layui.js}"></script>
<script type="text/javascript" th:inline="none">

    layui.use('table', function () {
        var table = layui.table;

        //编辑谈心记录
        function edit(id) {
            layer.open({
                type: 2,
                title: '编辑谈心记录',
                maxmin: true, //开启最大化最小化按钮
                area: ['600px', '350px'],
                content: ['/chatrecord/toeditchat?chatid='+id] //这是链接你的页面地址 url
            })
        }

        //添加谈心记录
        $("#add").on('click',function(){
            layer.open({
                type: 2,
                title: '添加谈心记录',
                maxmin: true, //开启最大化最小化按钮
                area: ['600px', '350px'],
                content: ['/chatrecord/toaddchat']//这是链接你的页面地址 url
            });
        });


        //监听行工具事件
        table.on('tool(tab)', function (obj) {

            var data = obj.data;
            var id = data.Chatid;
            if(obj.event === 'edit'){
                edit(id);
            }else if(obj.event === 'del'){
                layer.confirm('真的删除么?', function (index) {
                    obj.del();
                    layer.close(index);
                    $.ajax({
                        url: '/chatrecord/delchatrecord',
                        type: 'post',
                        data: {
                            id:data.Chatid
                        },
                        dataType: 'text'
                    })
                });
            }
        });
    });
</script>
</html>